using System;
using bitzhuwei.Compiler;

namespace bitzhuwei.GLSLFormat {
    /// <summary>
    /// Correspond to the Vn node primary_expression in the grammar(GLSL).
    /// </summary>
    internal partial class Vnprimary_expression : IFullFormat {
        // [007] primary_expression = variable_identifier ;
        // [008] primary_expression = 'intConstant' ;
        // [009] primary_expression = 'uintConstant' ;
        // [010] primary_expression = 'floatConstant' ;
        // [011] primary_expression = 'boolConstant' ;
        // [012] primary_expression = 'doubleConstant' ;
        // [013] primary_expression = '(' expression ')' ;


        private readonly IFullFormat complex;

        private readonly TokenRange _scope;
        public TokenRange Scope => _scope;
        public void FullFormat(BlankConfig? preConfig, TextWriter writer, FormatContext context) {
            context.PrintBlanksAnd(this.complex, preConfig, writer);
        }


        // [007] primary_expression = variable_identifier ;
        public Vnprimary_expression(Vnvariable_identifier r0) {
            this.complex = new complex0(r0);
            this._scope = new TokenRange(r0);
        }
        class complex0 : IFullFormat {
            private readonly TokenRange _scope;
            public TokenRange Scope => _scope;
            public void FullFormat(BlankConfig? preConfig, TextWriter writer, FormatContext context) {
                context.PrintBlanksAnd(r0, preConfig, writer);
            }
            public readonly Vnvariable_identifier r0;
            public complex0(Vnvariable_identifier r0) {
                this.r0 = r0;
                this._scope = new TokenRange(r0);
            }
        }

        // [008] primary_expression = 'intConstant' ;
        public Vnprimary_expression(Token r0) {
            this.complex = new complex1(r0);
            this._scope = new TokenRange(r0);
        }
        class complex1 : IFullFormat {
            private readonly TokenRange _scope;
            public TokenRange Scope => _scope;
            public void FullFormat(BlankConfig? preConfig, TextWriter writer, FormatContext context) {
                context.PrintBlanksAnd(r0, preConfig, writer);
            }
            public readonly Token r0;
            public complex1(Token r0) {
                this.r0 = r0;
                this._scope = new TokenRange(r0);
            }
        }

        // [009] primary_expression = 'uintConstant' ;
        // complex2 repeated with complex1

        // [010] primary_expression = 'floatConstant' ;
        // complex3 repeated with complex1

        // [011] primary_expression = 'boolConstant' ;
        // complex4 repeated with complex1

        // [012] primary_expression = 'doubleConstant' ;
        // complex5 repeated with complex1

        // [013] primary_expression = '(' expression ')' ;
        public Vnprimary_expression(Token r2, Vnexpression r1, Token r0) {
            this.complex = new complex6(r2, r1, r0);
            this._scope = new TokenRange(r2, r0);
        }
        class complex6 : IFullFormat {
            private readonly TokenRange _scope;
            public TokenRange Scope => _scope;
            public void FullFormat(BlankConfig? preConfig, TextWriter writer, FormatContext context) {
                var config = new BlankConfig();
                context.PrintBlanksAnd(r2, preConfig, writer);
                context.PrintCommentsBetween(r2, r1, config, writer);
                context.PrintBlanksAnd(r1, config, writer);
                context.PrintCommentsBetween(r1, r0, config, writer);
                context.PrintBlanksAnd(r0, config, writer);
            }
            public readonly Token r2;
            public readonly Vnexpression r1;
            public readonly Token r0;
            public complex6(Token r2, Vnexpression r1, Token r0) {
                this.r2 = r2;
                this.r1 = r1;
                this.r0 = r0;
                this._scope = new TokenRange(r2, r0);
            }
        }



    }
}
